package com.wlb365.financing.modules.sys.controller;

import com.wlb365.financing.common.utils.ShiroUtil;
import com.wlb365.financing.common.support.controller.BaseController;
import com.wlb365.financing.common.dto.R;
import com.wlb365.financing.modules.sys.entity.User;
import com.wlb365.financing.modules.sys.service.IMenuService;
import com.wlb365.financing.modules.sys.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * 概述：首页加载
 * </p>
 *
 * @author zwh
 * @version 1.0
 * @copyRight 北京微利宝信息技术有限公司  All right reserved.
 * @date 2020/3/21
 */
@RestController
@Slf4j
public class IndexController extends BaseController {

    @Autowired
    private IMenuService menuService;

    @Autowired
    private IUserService userService;

    @GetMapping(value = "/")
    public ModelAndView index() {
        User user = userService.getById(ShiroUtil.getUserId());
        return new ModelAndView("index").addObject("authUserInfo", user);
    }

    @GetMapping(value = "home")
    public ModelAndView home() {
        return new ModelAndView("home");
    }

    @GetMapping(value = "test")
    public ModelAndView test() {
        return new ModelAndView("test");
    }


    @GetMapping(value = "index/menus")
    public R menus() {
        return R.ok(menuService.listUserPermissionMenuWithSubByUserId(ShiroUtil.getUserId()));
    }

    @GetMapping(value = "index/navMenus")
    public R navMenus() {
        return R.ok(menuService.listUserPermissionNavMenuByUserId(ShiroUtil.getUserId()));
    }

    @GetMapping(value = "index/shortcutMenus")
    public R shortcutMenus() {
        return R.ok(menuService.listUserPermissionShortcutMenuByUserId(ShiroUtil.getUserId()));
    }
}
